home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / xlib.doc < prev    next >
Text File  |  1995-03-31  |  8KB  |  220 lines

  1. (Comp.sys.handhelds) 
  2. Item: 1874 by n233dk at tamuts.tamu.edu 
  3. Author: [Rick Grevelle] 
  4.   Subj: ROM XLIB's (Hidden ROM) 
  5.   Date: Fri Feb 01 1991 
  6.  
  7.     [Note: The IO.DOC file in the HORN2 directory on the EduCALC Goodies 
  8.     Disk #2 makes a reference to the file "XLIB.DOC on this [#2] disk" 
  9.     whereas in fact there is no such file on that disk.  The file XLIB.DOC 
  10.     is an edited version of an excellent article by Rick Grevelle about 
  11.     XLIB numbers, and how to create them, split them, and recall the 
  12.     programs they refer to.  It was accidentally omitted from the disk. 
  13.     Better late than never... here it is...  -jkh-]  
  14.  
  15. For those individuals who are currently interested in the 48's internals, the 
  16. following information should be somewhat helpful as far as the use of XLIB's in 
  17. system RPL is concerned.  XLIB's are frequently found within an RPL instruction 
  18. stream.  Unthreading STO reveals that a system RPL call made to another RPL 
  19. routine, which contains an XLIB object in its instruction stream, can seemingly 
  20. lead to a dead end.  This is, for the most part, due to the fact it has been 
  21. impossible to determine where the system RPL is that's executed when the XLIB 
  22. is evaulated.   
  23.  
  24. Now it should be understood that it is ROM based XLIB's I'm referring to in the 
  25. above, but the following details can be applied to library XLIB's as well.  The 
  26. whereabouts of the RPL routine, which is executed when any of the libraries' 
  27. XLIB's are evaluated, can be easily determined simply by reading the link table 
  28. within that library.  Since this has already been explained by several 
  29. individuals, and is not crucial to an understanding of the material about to be 
  30. disclosed, a rediscussion will be avoided.   
  31.  
  32. As previously mentioned, the system RPL which constitutes the STO command, and 
  33. begins at #20CCDh, when unthreaded reveals several system RPL routines which 
  34. contain XLIB objects embedded in their instruction streams.  A good example of 
  35. this can be found in the RPL routine responsible for storing a backup or a 
  36. library object in level two, to the port specified by the real number in level 
  37. one.  Located at #215BFh, this RPL routine utilizes what is in fact "XLIB 240 
  38. 95", and when evaluated, executes the system RPL which is responsible for the 
  39. actual storing of the stack arguments just described.   
  40.  
  41. But where in ROM is the system RPL located that is executed when the XLIB is 
  42. evaluated?  Well in my version E, it's at #7F7BDh, and is the ROM that's 
  43. normally covered by RAM.  This is why some system RPL has to utilize XLIB's to 
  44. call other system RPL routines.  RPL can't call any of the entry points in the 
  45. "hidden" ROM by simply placing the address of the desired routine in the RPL 
  46. instruction stream.  Accessing entry points in the hidden ROM requires bank 
  47. switching, and it's XLIB's which possess this ability.  HP uses XLIB's in their 
  48. system RPL to access the various entry points in the hidden ROM.   
  49.  
  50. The following programs utilize several prefixed machine routines which will aid 
  51. in the manipulation of these previously illusive ROM-based XLIB's.  Only one of 
  52. the four routines included here do I consider to be slightly kludged.  And 
  53. although short, all four provide powerful new tools for manipulating all 
  54. XLIB's.  For the sake of time a SYSEVAL type listing of the routines is used as 
  55. explanation.   
  56.  
  57.  
  58. \->XLIB take two real numbers as arguments and returns the appropriate 
  59. XLIB. 
  60.  
  61.                 Arguments                       Results 
  62.         4:                              4: 
  63.         3:                              3: 
  64.         2:              240             2: 
  65.         1:               95             1:      XLIB 240 95 
  66.  
  67.  
  68. \->XLIB 
  69.  
  70. 02D9D  begin RPL 
  71. 18A8D    need 2 arguments 
  72. 18FB2    check arguments 
  73. 04099    real, real <11h> 
  74. 02D9D    begin RPL 
  75. 18CEA      real\->system binary 
  76. 03223      swap 
  77. 18CEA      real\->system binary 
  78. 03223      swap 
  79. 07E50      \->xlib 
  80. 0312B    end rpl 
  81. 0312B  end rpl 
  82.  
  83.  
  84. \->XLIB 
  85.  
  86. %%HP: T(3)A(D)F(.); 
  87. "D9D20D8A812BF8199040D9D20AEC8132230AEC813223005E70B2130B213097F3" 
  88.  
  89.  
  90.  
  91. XLIB\-> requires an XLIB argument, and is is the reversal of the above. 
  92.  
  93.  
  94.                 Arguments                       Results 
  95.         4:                              4: 
  96.         3:                              3: 
  97.         2:                              2:              240 
  98.         1:      XLIB 240 95             1:               95 
  99.  
  100.  
  101. XLIB\-> 
  102.  
  103. 02D9D  begin rpl 
  104. 18AB2    need 1 argument 
  105. 18FB2    check argument 
  106. 04085    system binary <Fh> 
  107. 02D9D    begin rpl 
  108. 08CCC      xlib\-> 
  109. 18DBF      system binary\->real 
  110. 03223      swap 
  111. 18DBF      system binary\->real 
  112. 03223      swap 
  113. 0312B    end rpl 
  114. 0312B  end rpl 
  115.  
  116.  
  117. XLIB\-> 
  118.  
  119. %%HP: T(1)A(D)F(.); 
  120. "D9D202BA812BF8158040D9D20CCC80FBD8132230FBD8132230B2130B21306983" 
  121.  
  122.  
  123. Although the previous two routines are quite useful, they are trivial by 
  124. comparison to the next.  X\->R is an XLIB-to-RPL conversion scheme where upon 
  125. an XLIB argument is taken, and the RPL routine that would normally be executed 
  126. when the XLIB is evaluated is returned.  So if it were system RPL that resides 
  127. in the hidden ROM, the level one result would contain the unevaluated routine 
  128. to which the XLIB calls.  There is no longer any need for guessing, simply use 
  129. HEX\-> on the stack object to examine it.  Or use PRG\-> to unthread, and then 
  130. HEX\-> to acquire the individual addresses for the externals.  The applications 
  131. here are quite obviously multiple.   
  132.  
  133.  
  134.                 Arguments                       Results 
  135.         4:                              1:  External External 
  136.         3:                                  <2h> External 
  137.         2:                                  External External 
  138.         1:                                  External External 
  139.  
  140.  
  141. X\->R 
  142.  
  143. 02D9D  begin rpl 
  144. 18AB2    need 1 argument 
  145. 18FB2    check argument 
  146. 04085    system binary <Fh> 
  147. 02D9D    begin rpl 
  148. 07E99      xlib\->rpl 
  149. 61A3B      return if true 
  150. 05016      errn #004 
  151. 0312B    end rpl 
  152. 0312B  end rpl 
  153.  
  154.  
  155. X\->R 
  156.  
  157. %%HP: T(1)A(D)F(.); 
  158. "D9D202BA812BF8158040D9D2099E70B3A1661050B2130B2130470B" 
  159.  
  160.  
  161. Lastly, is the above routine's reverse scheme, as this is exactly how it 
  162. functions.  It takes the above result as an argument and returns as its result 
  163. the argument with which we started.   
  164.  
  165.  
  166.  
  167.                 Arguments                       Results 
  168.         1:  External External           4: 
  169.             <2h> External               3: 
  170.             External External           2: 
  171.             External External           1:      XLIB 240 95 
  172.  
  173.  
  174. R\->X 
  175.  
  176. 02D9D  begin rpl 
  177. 18AB2    need 1 argument 
  178. 18FB2    check argument 
  179. 0403F    system binary <8h> 
  180. 02D9D    begin rpl 
  181. 07E76      rpl\->xlib 
  182. 07E99      xlib\->rpl 
  183. 0712A      jump next call/object if true 
  184. 11056      errn #12D 
  185. 07E76      rpl\->xlib 
  186. 0312B    end rpl 
  187. 0312B  end rpl 
  188.  
  189.  
  190. R\->X 
  191.  
  192. %%HP: T(1)A(D)F(.); 
  193. "D9D202BA812BF81F3040D9D2067E7099E70A21706501167E70B2130B2130D796" 
  194.  
  195.  
  196. Some final notes.  The information which appears here in regards to the four 
  197. prefixed machine routines #07E50h, #08CCCh, #07E99h, and #07E76h, is the result 
  198. of my own experimentation, and in no way came from HP.  I would also recommend 
  199. disassembling #07E99h for further study to those interested in how the 48 
  200. accesses the hidden ROM.  Good luck.   
  201.  
  202. Rick Grevelle  
  203.  
  204. [Note from Joe Horn: If you have Rick's HACKIT library in your HP 48, you do 
  205. not need the first three routines above.  Use the following HACKIT routines 
  206. instead: 
  207.  
  208.         Instead of:                  Use: 
  209.          --------                  -------- 
  210.           ->XLIB         -->        ->XLIB   \ 
  211.           XLIB->         -->        OUT->     >--> in the HACKIT library 
  212.           X->R           -->        RCLIB    / 
  213.  
  214. HACKIT's functions each have more functionality too.  ->XLIB accepts real or 
  215. binary integer arguments.  OUT-> not only pulls apart XLIBs but also arrays of 
  216. string (or of any other kind), lists, programs, and algebraics.  And RCLIB not 
  217. only extracts single XLIB commands from their libraries, but if given a real 
  218. number or global name as its argument, will recall the entire library as a 
  219. directory.  -jkh-]  
  220.